<?php

namespace App\Admin\Actions\Waybill;

use Encore\Admin\Actions\Action;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class ClearAll extends Action
{
    protected $selector = '.clear-all';

    public function handle(Request $request)
    {
        // $request ...
        DB::table('waybills')->truncate();

        return $this->response()->success('操作成功')->refresh();
    }

    public function html()
    {
        return <<<HTML
        <a class="btn btn-sm btn-default clear-all">一键清空</a>
HTML;
    }

    public function dialog()
    {
        $this->confirm('确定将运单全部清空吗？');
    }
}